authApp.controller("loginController",function($scope,$http,$cookieStore,$cookies){
	$scope.cancellogin=function(){
		var random=Math.random();
		location.href=paths.projectHome+"?random="+random;
	}
	$scope.login=function(){
		if(!$scope.user){
			alert("请填写用户名");
			return
		}
		if(!$scope.password){
			alert("请填写密码");
			return
		}
		if($scope.user!=""&&$scope.password!=""){
            var pass=$scope.password;
            pass=sha256_digest(pass);
			$http({
				method:'post',
				url:apis.investigaLogin,
				data:{'account':$scope.user,'password':pass,'major':$scope.eType,'status':$scope.sType, user_type: 2}
			}).success(function(response){
				var radom=Math.random();
				if(response.code=="000000"){
					$cookies.put('account',$scope.user,{"path":"/"});
					$cookies.put('accounttype','investiga',{"path":"/"});
					$cookies.put('employerName',response.data.expertName,{"path":"/"});
					$cookies.put('investigaPid',response.data.userId,{"path":"/"});
					$cookies.put('investigaType',response.data.identity,{"path":"/"});
					//location.href=paths.investigalHome+"?radom="+radom;
					location.href=paths.investigalHome;
				}else{
					alert(response.errorMsg);
				}
			}).error(function(){
				alert("服务器打瞌睡了，请稍等！");
			})
		}
	}
})